////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRay_GooBossTurret extends BailterRay_GooAdvancedTurret
                     placeable;

simulated function Tick(float DeltaTime)
{
   local BailterRayPawn PC;
   local rotator IntendedAim;

   if(!PlayerCanSeeMe())
       return;

   forEach VisibleCollidingActors(class'BailterRayPawn', PC, 1640)
   {
       if(PC.IsHumanControlled())
       {
         break;
       }
   }

   if(PC != none && PC.IsHumanControlled())
   {
       IntendedAim = rotator(PC.Location - WeaponComponent.GetPosition());

       if(IntendedAim.Yaw < -16384 || IntendedAim.Yaw > 16384)
           IntendedAim.Pitch = -16384 - (16384 + IntendedAim.Pitch);

        //Incase the turret was rotated in the editor!
       IntendedAim = IntendedAim - Self.Rotation;
       CurrentAim = WeaponComponent.Rotation;

       if(IntendedAim.Pitch - CurrentAim.Pitch <= 1600 && IntendedAim.Pitch - CurrentAim.Pitch >= -1600)
       {
            CurrentAim.Pitch = IntendedAim.Pitch;
            WeaponComponent.SetRotation(CurrentAim);
            Super.Tick(DeltaTime);
       }
       if(IntendedAim.Pitch - CurrentAim.Pitch > 1600)
       {
            CurrentAim.Pitch += deltaTime * ROTATION_SPEED;
            WeaponComponent.SetRotation(CurrentAim);
       }
       if(IntendedAim.Pitch - CurrentAim.Pitch < -1600)
       {
            CurrentAim.Pitch -= deltaTime * ROTATION_SPEED;
            WeaponComponent.SetRotation(CurrentAim);
       }

       // Also done in super, but we dont always use super!
       HeadCollision.SetTranslation(vector(WeaponComponent.Rotation) * 22);
   }
}

defaultproperties
{
    Health = 400

    //Base of Turret
    Begin Object Name=BaseMesh
        SkeletalMesh=SkeletalMesh'BailterRayAssetPackage.Meshes.PlantTurretBase'
        CollideActors=True
        BlockActors=True
        Scale = 2.3
    End Object
    BaseComponent=BaseMesh
    Components.Add(BaseMesh)

    //Head of Turret
    Begin Object Name=HeadMesh
        SkeletalMesh=SkeletalMesh'BailterRayAssetPackage.Meshes.PlantTurretHead'
        CollideActors=True
        BlockActors=True
        Rotation=(Pitch = -16384, Yaw = 0, Roll = 0)
        Scale = 2.3
	End Object
	WeaponComponent=HeadMesh
	Components.Add(HeadMesh)

    //Turret Type
    Begin Object Name=Proj
		ProjectileClass=class'BailterRayProj_Goo'
		MuzzleFlash=ParticleSystem'WP_BioRifle.Particles.P_WP_Bio_3P_MF'
		DeathEffect=ParticleSystem'WP_BioRifle.Particles.P_WP_Bio_Alt_Blob_POP'
		DeathSound = SoundCue'A_Weapon_BioRifle.Weapon.A_BioRifle_FireAltImpactExplode_Cue'
		FireSound = SoundCue'A_Character_BodyImpacts.BodyImpacts.A_Character_BodyImpact_GibLarge_Cue'
		FireInterval=1
	End Object
	GooTurret=Proj

	//Collision
	Begin Object name=CollisionBase
		CollisionRadius=35.0
		CollisionHeight=55.0
        CollideActors=True
        BlockActors=True
	End Object
    BaseCollision = CollisionBase
    Components.Add(CollisionBase)

   	Begin Object name=CollisionHead
		CollisionRadius=32.0
		CollisionHeight=32.0
        CollideActors=True
        BlockActors=True
	End Object
    HeadCollision = CollisionHead
    Components.Add(CollisionHead)
}